"""
Soraia Janeiro
filas de espera
aula6
"""

class FilaEspera(list):
	def __init__(self, n):
		for k in range(n):
			self.append(0)
		self.length = n - 1
		self.head = 0
		self.tail = 0
	def enqueue(self, x):
		self[self.tail] = x
		if self.tail == self.length:
			self.tail = 0
			pass
		else:
			self.tail = self.tail + 1
			pass
		pass
	
		
class Fila():
	def __init__(n):
		self.length = n - 1
		self.head = 0
		self.tail = 0
		self.Q = [0 for k in range(n)]
		
	def enqueue(self, x):
		self.Q[self.tail] = x
		if self.tail == self.length:
			self.tail = 0
			pass
		else:
			self.tail = self.tail + 1
			pass
		pass
	
	def dequeue(self):
		x = self.Q[self.head]
		if self.head == self.length:
			self.head = 0
			pass
		else:
			self.head = self.head + 1
		return x
		
			
		
